# Maintainer: Lukas Fleischer <lfleischer@archlinux.org>

pkgname=python-pytest-tap
_pyname=${pkgname#python-}
pkgver=3.3
pkgrel=2
pkgdesc="Test Anything Protocol (TAP) reporting plugin for pytest."
arch=(any)
url="https://github.com/python-tap/pytest-tap"
license=('BSD')
depends=('python-pytest' 'python-tappy')
makedepends=('python-setuptools')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/python-tap/pytest-tap/archive/v${pkgver}.tar.gz
        https://github.com/python-tap/pytest-tap/commit/4ed0138b.patch)
sha256sums=('6f3f7895e005c19391be46dc592182d52c9368fe7c4a5bec292ba4632314ff42'
            '459d4040ecaa5a088330c99800695c3e688b22bda6fd6b4aa8a30da85012085f')

prepare() {
  patch -d $_pyname-$pkgver -p1 < 4ed0138b.patch # Fix tests
}

build() {
	cd "${srcdir}/${_pyname}-${pkgver}"
	python setup.py build
}

check() {
	cd "${srcdir}/${_pyname}-${pkgver}"
	local python_version=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
	python setup.py install --root="${srcdir}/tmp_install" --optimize=1
	PYTHONPATH="${srcdir}/tmp_install/usr/lib/python${python_version}/site-packages" pytest
}

package() {
	cd "${srcdir}/${_pyname}-${pkgver}"
	python setup.py install --root="${pkgdir}" --prefix=/usr --optimize=1
}
